const TOKEN_KEY = 'tonke';
const LIST_NUMBER = 'listNumber';
const NAME = 'name';
const USERJOBNUMBER = 'userJobNumber';
const USERUNITS = 'userUnits';
const USERUNITSNUMBER = 'userUnitsNumber';

const isLogin = () => {
  return !!sessionStorage.getItem(TOKEN_KEY);
};

const getToken = () => {
  return sessionStorage.getItem(TOKEN_KEY);
};

const setToken = (token: string) => {
  sessionStorage.setItem(TOKEN_KEY, token);
};

const clearToken = () => {
  sessionStorage.removeItem(TOKEN_KEY);
};

const getListNumber = () => {
  return sessionStorage.getItem(LIST_NUMBER);
};

const setListNumber = (listNumber: string) => {
  sessionStorage.setItem(LIST_NUMBER, listNumber);
};

const clearListNumber = () => {
  sessionStorage.removeItem(LIST_NUMBER);
};

// 用户名
const getName = () => {
  return sessionStorage.getItem(NAME);
};

const setName = (name: string) => {
  sessionStorage.setItem(NAME, name);
};

const clearName = () => {
  sessionStorage.removeItem(NAME);
};
// 工号
const getUserJob = () => {
  return sessionStorage.getItem(USERJOBNUMBER);
};

const setUserJob = (userJobNumber: string) => {
  sessionStorage.setItem(USERJOBNUMBER, userJobNumber);
};

const clearUserJob = () => {
  sessionStorage.removeItem(USERJOBNUMBER);
};
// 部门
const getUserUnits = () => {
  return sessionStorage.getItem(USERUNITS);
};

const setUserUnits = (userUnits: string) => {
  sessionStorage.setItem(USERUNITS, userUnits);
};

const clearUserUnits = () => {
  sessionStorage.removeItem(USERUNITS);
};

const getUserUnitsNumber = () => {
  return sessionStorage.getItem(USERUNITSNUMBER);
};

const setUserUnitsNumber = (userUnitsNumber: string) => {
  sessionStorage.setItem(USERUNITSNUMBER, userUnitsNumber);
};

const clearUserUnitsNumber = () => {
  sessionStorage.removeItem(USERUNITSNUMBER);
};

export {
  isLogin,
  getToken,
  setToken,
  clearToken,
  getListNumber,
  setListNumber,
  clearListNumber,
  getName,
  setName,
  clearName,
  getUserJob,
  setUserJob,
  clearUserJob,
  getUserUnits,
  setUserUnits,
  clearUserUnits,
  getUserUnitsNumber,
  setUserUnitsNumber,
  clearUserUnitsNumber,
};
